package com.itheima.edu.info.manager.C_Service;

import com.itheima.edu.info.manager.D_Dao.StudentDao;
import com.itheima.edu.info.manager.E_domain.Student;

import java.util.ArrayList;

public class StudentService {
    ArrayList<Student> list;
    StudentDao sd = new StudentDao();
    //判断ID是否相同，相同为true，不同false
    int index;

    public boolean panDuanID(String id) {
        boolean bl = false;
        list = sd.geArrayList();
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            if (s.getID().equals(id)) {
                index = i;
                return bl = true;
            }
        }
        return bl;
    }

    public void tianjia(Student st) {
        sd.tianjia(st);
    }

    public ArrayList<Student> chaKan() {

        return sd.geArrayList();
    }

    public void xiuGai(Student st) {
        list.set(index, st);
        System.out.println("修改成功");


    }


    public void shanChu(String s) {
        panDuanID(s);
        sd.shanChu(index);

    }
}
